package com.fone.player.play.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.fone.player.ApplicationManage;
import com.fone.player.R;

/**
 * 倍速菜单适配器
 * 
 * @author kongxiaojun
 * @since 2014-5-21
 */
public class MenuRateAdapter extends BaseAdapter {

	/**
	 * 倍速状态
	 */
	private int currentRate = 0;

	public MenuRateAdapter(int currentRate) {
		super();
		this.currentRate = currentRate;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return 4;

	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = LayoutInflater.from(ApplicationManage.getAplicationManageInstance()).inflate(R.layout.player_full_second_menu_item, null);
		TextView tv = (TextView) convertView.findViewById(R.id.second_menu_3d_text);
		View divider = convertView.findViewById(R.id.second_menu_3d_divider);
		switch (position) {
		case 0:
			tv.setText(R.string.player_rate_low);
			break;
		case 1:
			tv.setText(R.string.player_rate_normal);
			break;
		case 2:
			tv.setText(R.string.player_rate_hige);
			break;
		case 3:
			tv.setText(R.string.player_rate_two);
			break;
		}

		if (currentRate == position) {
			tv.setTextColor(ApplicationManage.getAplicationManageInstance().getResources().getColor(R.color.video_info_tab_line));
		} else {
			tv.setTextColor(ApplicationManage.getAplicationManageInstance().getResources().getColor(R.color.white));
		}
		if (position == 3) {
			divider.setVisibility(View.GONE);
		} else {
			divider.setVisibility(View.VISIBLE);
		}
		return convertView;
	}

}
